var gulp 			= require('gulp');
var watch 			= require('gulp-watch');
var webpack 		= require('gulp-webpack');


 
var CONFIG_ENTRY = {
	home: './js/main.js',
	register: './js/register.js',
	login: './js/login.js',
	index: './js/index.js',
	user: './js/user.js',
	shoppingcart: './js/shoppingcart.js',
	pay: './js/pay.js',
	personinfo: './js/personinfo.js',
	order: './js/order.js',
	product: './js/product.js',
	comment: './js/comment.js',
	mercury: './js/mercury.js'
}

//jquery版本脚本
gulp.task('js', function(callback){
	watch('./js/**/*.js', function(){
		gulp.src('./js/main.js')
			.pipe(webpack({
				entry: CONFIG_ENTRY,
				watch: true,
				output: {
					filename: '[name].build.js'
				},
				module: {
			        loaders: [
						// { test: /\.css$/, loader: "style!css" },
						// required for react jsx
						//{ test: /\.js$/,    loader: "babel-loader" },
						{
							test: /\.js$/,
							exclude: /(node_modules|bower_components)/,
							loader: 'babel-loader',
							query: {
						     	presets: ['es2015']
						    }
						}
			        ]
			    }
			}))
			.pipe(gulp.dest('../js'))
		 
	});
});

 

gulp.task('default', function(){
	gulp.run(['js']);
});
